<?php
/**
 *	FILENAME: 		/server_app/newswire_section_stories.php
 *	DESCRIPTION:	This backend script produces a JSON response representing a list story titles and IDs given a section name of the current newswire.
 *	AUTHOR:			Casey Burkhardt 
 *	VERSION:		1.1.0
 *	LAST MODIFIED:	11/7/2010
 **/

require_once($_SERVER['DOCUMENT_ROOT'] . "/config/environment.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/functions.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/logging.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/newswire.php");

enforceSSL();
setRequestParameters();

$sectionName = $_PARAMETERS["section"];

// Obtain the issue and section information
$timeStamp = getNewswireTimestamp();
$storyData = getStoryData($sectionName);

// Check the returned results for validity.
if ($timeStamp === FALSE || $storyData === FALSE) {
    $response["response_type"] = "error";
    $response["error_desc"] = "Unable to obtain Wildcat Newswire information.";
    logError("Unable to obtain Newswire data");
    echo(json_encode($response));
    die();
} else {
    $response["response_type"] = "success";
    $response["issue_timestamp"] = $timeStamp;
    $response["story_data"] = $storyData;
    logAction("Returned Newswire story data");
    echo(json_encode($response));
    die();
}
?>
